
public class CloseButtonNationality extends Component {
	public boolean clicked;
	public boolean active;
	public Nationality nationality;
	////////////////////////////////////////////////////////////////////////////////////////////////////
	public CloseButtonNationality(Nationality nationality)
	{
		super();
		width=12;
		height=12;
		clicked = false;
		active = false;
		this.nationality = nationality;
		this.label = nationality.getName();
	}
	public void draw()
	{
		GLOBAL.processing.rectMode(GLOBAL.processing.CORNER);
		GLOBAL.processing.stroke(128);
		GLOBAL.processing.strokeWeight(1);
		GLOBAL.processing.noFill();
		GLOBAL.processing.rect(x, y, width, height);
		GLOBAL.processing.stroke(128);
		GLOBAL.processing.line(x+2, y+2, x+width-2, y+height-2);
		GLOBAL.processing.line(x+width-2, y+2, x+2, y+height-2);
		
		GLOBAL.processing.textFont(GLOBAL.plotFont, 14);
		GLOBAL.processing.fill(GLOBAL.textColor);
		if((int)(GLOBAL.processing.textWidth(label))>120){
			GLOBAL.processing.text(label.substring(0, GLOBAL.processing.min(16,label.length()))+"...", x+20, y + 11);
		}
		else GLOBAL.processing.text(label, x + 20, y + 11);
		
		if(GLOBAL.analysisType == 1){
			if(!GLOBAL.continents_colors){// Nationality color
				GLOBAL.processing.stroke(nationality.color);
			}
			else{// Continent color
				GLOBAL.processing.stroke(nationality.continent.color);
			}
			GLOBAL.processing.strokeWeight((float)2.5);
			GLOBAL.processing.line(x+20, y+16, x+122, y+16);
			
		}
		
		
		if(mouseOver()) 
		{
			super.draw();

		}
		
		if(GLOBAL.processing.mouseX > x+width && 
				GLOBAL.processing.mouseX < x + 130 &&
				 GLOBAL.processing.mouseY> y && GLOBAL.processing.mouseY < y +height){
			createMouseOver();

		}

	}

	
	// Draw entire label on mouseOver for too long labels
		public void createMouseOver(){
			
			int w = (int)(GLOBAL.processing.textWidth(label));
			if(w<=120) return;
			
			GLOBAL.selectionPanel.xHighLight = x+130+20;
			GLOBAL.selectionPanel.yHighLight = y - 5;
			GLOBAL.selectionPanel.stringHighLight = label;

		}
	
	
	////////////////////////////////////////////////////////////////////////////////////////////////////
	String label;

	public void mouseCliked() {
		clicked = !clicked;
	}
}
